package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;

import javax.swing.BorderFactory;
import javax.swing.JComponent;

import settings.guiSettings;

public class FieldBackground extends JComponent{
	private static final long serialVersionUID = -4107599198135663244L;
	private Graphics2D graphic;
	public FieldBackground() {
		setLayout(new GameFieldBackgroundLayoutManager());
		setSize(421,421);
		setLocation(10, 10);
		setBorder(BorderFactory.createLineBorder(Color.BLACK));
	}
	protected void paintComponent(Graphics g) {
		graphic = (Graphics2D)g;
		graphic.setColor(guiSettings.GAMECOLOR_BLUE);
		graphic.fillRect(0, 0, 210, 10);
		graphic.fillRect(0, 0, 10, 210);
		
		graphic = (Graphics2D)g;
		graphic.setColor(guiSettings.GAMECOLOR_RED);
		graphic.fillRect(410-210, 0, 210, 10);
		graphic.fillRect(410, 0, 10, 210);
		
		graphic = (Graphics2D)g;
		graphic.setColor(guiSettings.GAMECOLOR_GREEN);
		graphic.fillRect(410, 410-210, 10, 220);
		graphic.fillRect(410-210, 410, 220, 10);

		
		graphic = (Graphics2D)g;
		graphic.setColor(guiSettings.GAMECOLOR_YELLOW);
		graphic.fillRect(0, 410-210, 10, 210);
		graphic.fillRect(0, 410, 200, 10);
	}
	public class GameFieldBackgroundLayoutManager implements LayoutManager {
		public void addLayoutComponent(String name, Component comp) {}
		public void layoutContainer(Container parent) {}
		public Dimension minimumLayoutSize(Container parent) {
			return null;
		}
		public Dimension preferredLayoutSize(Container parent) {
			return new Dimension(600, 400);
		}
		public void removeLayoutComponent(Component comp) {}
	}
}
